package vip.web3.admin.sys.service.base;



import vip.web3.admin.sys.vo.base.LpDataVo;
import vip.web3.admin.sys.vo.base.WalletVo;

import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.concurrent.ExecutionException;

/**
 * @description: web3j
 * @author: allen
 * @create: 2021-07-20 13:39
 **/
public interface Web3jService {

    WalletVo createWallet();
    BigInteger getTransactionByHash(String server, String hash);

    /**
     * contractAddress 合约地址为空时, 为获取本币余额
     * @param server
     * @param address
     * @param contractAddress
     * @return
     * @throws IOException
     */
    BigDecimal getBalance(String server, String address, String contractAddress) throws IOException;

    BigDecimal totalSupply(String server, String contractAddress) throws IOException;

    LpDataVo getReserve(String server, String contractAddress) throws IOException;

    String getPair(String server, String factoryAddress,String token0,String token1) throws IOException;

    String getToken0(String server, String contractAddress) throws IOException;

    String getToken1(String server, String contractAddress) throws IOException;

    String approve(String server,
                   String contractAddress,
                   String spender,
                   BigInteger amount,
                   String encryptionPrivateKey,
                   String sendAddress) throws IOException;

    String addLiquidity(String server,
                          String lpAddress,
                          String contractAddress,
                          String tokenA,
                          String tokenB,
                          BigInteger amountADesired,
                          BigInteger amountBDesired,
                          String to,
                          BigInteger deadline,
                          String encryptionPrivateKey,
                          String sendAddress) throws IOException;

    String removeLiquidity(String server,
                             String lpAddress,
                             String contractAddress,
                             String tokenA,
                             String tokenB,
                             BigInteger liquidity,
                             String to,
                             BigInteger deadline,
                             String encryptionPrivateKey,
                             String sendAddress) throws IOException;

    String swapExactTokensForTokens(String server,
                                    String otherAddress,
                                    String contractAddress,
                                    BigInteger amountIn,
                                    BigInteger amountOutMin,
                                    String[] path,
                                    String to,
                                    BigInteger deadline,
                                    String encryptionPrivateKey,
                                    String sendAddress) throws IOException;

    Boolean getTransactionResult(String server, String transactionHash) throws ExecutionException, InterruptedException;

    /**
     * contractAddress 合约地址为空时, 为本币转账
     * @param server
     * @param contractAddress
     * @param recipient
     * @param amount
     * @param encryptionPrivateKey
     * @param sendAddress
     * @return
     * @throws IOException
     */
    String transfer(String server,
                    String contractAddress,
                    String recipient,
                    BigInteger amount,
                    String encryptionPrivateKey,
                    String sendAddress) throws IOException;

    /**
     * 归集转账 contractAddress 合约地址为空时, 向目标地址转本币, BNB 或者 ETH, 即手续费, amount 传余额
     * 否则即将 目标地址上的合约代币 归集到冷钱包地址, 消耗以上手续费
     * @param server
     * @param contractAddress
     * @param recipient
     * @param amount
     * @param encryptionPrivateKey
     * @param sendAddress
     * @return
     * @throws IOException
     */
    String imputationTransfer(String server,
                    String contractAddress,
                    String recipient,
                    BigInteger amount,
                    String encryptionPrivateKey,
                    String sendAddress) throws IOException;

    String transferFrom(String server,
                    String contractAddress,
                    String sender,
                    String recipient,
                    BigInteger amount,
                    String encryptionPrivateKey,
                    String sendAddress) throws IOException;

    String getInviter(String server, String contractAddress, String address) throws IOException;

    String autoBurnLp(String server,
                      String contractAddress,
                      String controlAddress,
                      String encryptionPrivateKey) throws IOException;

    int getHoldersLength(String server,
                        String contractAddress,
                        String controlAddress) throws IOException;

    String dividends(String server,
                       BigInteger begin,
                       BigInteger end,
                       BigInteger fundUsdt,
                       String contractAddress,
                       String controlAddress,
                       String encryptionPrivateKey) throws IOException ;

    String nftRewardRelease(String server,
                            String contractAddress,
                            String controlAddress,
                            String encryptionPrivateKey,
                            String address,
                            BigInteger amount,
                            BigInteger invite) throws IOException;


    String farmRewardRelease(String server,
                            String contractAddress,
                            String controlAddress,
                            String encryptionPrivateKey,
                            String address,
                            BigInteger base,
                            BigInteger invite,
                            BigInteger steal) throws IOException;


    String addChainData(String server,
                         Integer type,
                         String contractAddress,
                         String controlAddress,
                         String encryptionPrivateKey,
                         String addr,
                         BigInteger amount) throws IOException;


    String setPledgeTotal(String server,
                           String contractAddress,
                           String controlAddress,
                           String encryptionPrivateKey,
                           BigInteger amount) throws IOException ;

    String chainReleaseOrMint(String server,
                                Integer type,
                                String contractAddress,
                                String controlAddress,
                                String encryptionPrivateKey) throws IOException ;

    String chainPlacementRelease(String server,
                                Integer type,
                                String contractAddress,
                                String controlAddress,
                                String encryptionPrivateKey) throws IOException ;

    int getActiveLength(String server,
                        String contractAddress,
                        String controlAddress,
                        String encryptionPrivateKey) throws IOException;

    String chainLpMint(String server,
                       BigInteger begin,
                       BigInteger end,
                       String contractAddress,
                       String controlAddress,
                       String encryptionPrivateKey) throws IOException ;

    String unlock(String server,
                  String contractAddress,
                  String address,
                  Integer type) throws IOException;

    String escape(String server,
                  String contractAddress,
                  String address,
                  Integer type) throws IOException;

    /**
     * 通过私钥签名
     * @param privateKey 私钥
     * @param content 签名内容
     * @return
     */
    String sign(String privateKey, String content);

    /**
     * 验证签名
     * @param signedData 签名后字符串
     * @param content 签名内容
     * @param address 地址
     * @return
     */
    boolean checkSign(String signedData, String content, String address);

}
